package com.tools.modules.monitor;

import com.tools.common.beans.constant.ControllerConstant;
import com.tools.common.beans.vo.Result;
import com.tools.controller.BaseController;
import com.tools.monitor.sys.CpuInfo;
import com.tools.monitor.sys.SystemUtil;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * 服务器控制器
 * @author ShangJY
 */
@RestController
@RequestMapping(ControllerConstant.API_MONITOR_PREFIX )
public class MonitorController extends BaseController {

    /**
     * 基础路径
     */
    private final String prefix = "monitor/";

    /**
     * 系统监控相关页面
     * @return
     */
    @GetMapping(value = {"sys","sys.html"})
    public ModelAndView monitor() {
        return jumpPage(prefix + "sys"+"/monitor");
    }

    @GetMapping("getCpuInfo")
    public Result getCpuInfo(){
        return Result.OK(SystemUtil.getCpu());
    }
}
